package com.mano.mall.service.callback.asyc;

import com.mano.mall.service.callback.factory.TemplateFactory;
import com.mano.mall.service.callback.template.AbstractPayCallbackTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
public class PayAsynCallbackService {

	/**
	 * 获取银联回调模版
	 */
	private static final String UNIONPAYCALLBACK_TEMPLATENAME = "unionPayCallbackTemplate";

	private static final String ALIPAYCALLBACK_TEMPLATENAME="aliPayCallbackTemplate";
	/**
	 * 银联异步回调通知
	 * 
	 * @return
	 */
	@RequestMapping("/unionPayAsynCallback")
	public String unionPayCallback(HttpServletRequest req, HttpServletResponse resp) {
		AbstractPayCallbackTemplate payCallbackTemplate = TemplateFactory
				.getPayCallbackTemplate(UNIONPAYCALLBACK_TEMPLATENAME);
		return payCallbackTemplate.asyncCallBack(req, resp);
	}

	/**
	 * 支付宝异步回调通知
	 * @param req
	 * @param resp
	 * @return
	 */
	public String aliPayCallback(HttpServletRequest req,HttpServletResponse resp){
		AbstractPayCallbackTemplate payCallbackTemplate = TemplateFactory
				.getPayCallbackTemplate(ALIPAYCALLBACK_TEMPLATENAME);
		return payCallbackTemplate.asyncCallBack(req, resp);
	}


}
